package com.bjc.principle.Inversion.improve;

/**
 * @program: DesignPattern
 * @description:
 * @author: bjc
 * @create: 2020-12-13 16:11
 */
public class DependencyInversion {

    public static void main(String[] args) {
        Person person = new Person();
        person.receive(new Email());
        person.receive(new WeiXin());
    }
}
//定义一个接口
interface IReceiver{
    public String getInfo();
}
class Email implements IReceiver{
    public String getInfo(){
        return "电子邮件信息：hello，world";
    }
}

//增加微信
class WeiXin implements IReceiver{
    public String getInfo(){
        return "微信信息：hello，ok";
    }
}


class Person{
    public void receive(IReceiver receiver){
        System.out.println(receiver.getInfo());
    }
}
